package ldkxingzhe.ldkxingzhedemo.widgets.XZListView;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import ldkxingzhe.ldkxingzhedemo.R;

/**
 * Created by xingzhe on 15/11/13.
 */
public class XZHeaderView extends LinearLayout{
    private final String TAG = XZHeaderView.class.getSimpleName();

    private LinearLayout mContainer;
    ViewGroup mContainerContent;
    XZListViewState mState;
    public XZHeaderView(Context context) {
        super(context);
        mContainer = (LinearLayout)LayoutInflater.from(context).inflate(R.layout.xz_header_view, null);
        LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);   // 默认情况下, header高度为0
        mState = XZListViewState.NORMAL;
        mContainerContent = (ViewGroup) mContainer.findViewById(R.id.xz_header_container);
        addView(mContainer, params); setGravity(Gravity.BOTTOM);
    }
    /**
     * 设置header的状态
     * @param state state
     * */
    public void setState(XZListViewState state){
        mState = state;
        switch (state){
            case NORMAL:
                break;
            case PULLING:
                break;
            case READY:
                break;
            case REFRESHING:
                break;
        }
    }

    public void setVisibleHeight(int height){
        if(height < 0){height = 0;}
        LinearLayout.LayoutParams params = (LayoutParams) mContainer.getLayoutParams();
        params.height = height;
        mContainer.setLayoutParams(params);
    }

    public int getVisibleHeight(){
        return mContainer.getLayoutParams().height;
    }
}
